home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 52
/
Aminet 52 (2002)(GTI - Schatztruhe)[!][Dec 2002].iso
/
Aminet
/
misc
/
emu
/
Apex-src.lha
/
PRHANA.68K
< prev
next >
Wrap
Text File
|
2001-09-30
|
8KB
|
267 lines
;PRHANA.68K SEP-01-88 (also see 4 copies of "INFOSTR")
;All-in-one printer handler for the Amiga.
;Written by Loren Blaney
;This is based on PRINTHAN.68K
;
;REVISION HISTORY:
;MAR-09-87, Original.
;MAY-18-87, Fixed long line wraparound, changed string termination.
;
;NOTES:
;This program is used to produce the following handlers, depending on
; the conditional assembly flags:
; PARHAN, EPSONHAN, ITOHAN, DUMHAN
;
;This printer handler paginates and handles tabs. The printer should be
; configured so that a <CR> moves to the start of the current line, and
; a <LF> moves down one line.
;This will print 60 lines per page, with a half-inch margin at the top
; and bottom. It is assumed that the page is 11 inches long and that
; there are 6 lines per inch.
NOLIST
INCLUDE SYSPAG ;Get system-page definitions
LIST
;Select only one of the following by setting it TRUE:
PARHAN EQU FALSE ;Non-specific printer handler
EPSONHAN EQU FALSE ;Epson printer handler
ITOHAN EQU TRUE ;C.Itoh printer handler
DUMHAN EQU FALSE ;Direct control, no pagination, etc.
DEVNUM EQU 2 ;Printer device number
IF EPSONHAN ! ITOHAN
LINESIZ EQU 96 ;Number of characters on a line
ELSE
LINESIZ EQU 80 ;Number of characters on a line
ENDIF
;I/O ADDRESSES:
CIAA EQU $BFE001 ;Base address of 8520-A
CIAB EQU $BFD000 ;Base address of 8520-B
;Offsets to certain CIAA registers:
PRA EQU $000 ;Port register A
PRB EQU $100 ;Port register B
DDRA EQU $200 ;Data direction register A
DDRB EQU $300 ;Data direction register B
SDR EQU $C00 ;Serial data register
ICR EQU $D00 ;Interrupt control register
CRA EQU $E00 ;Control register A
CRB EQU $F00 ;Control register B
ORG $7E900
START EQU @ ;Address where this handler starts
;=======================================================================
;PRINTER HANDLER
;
PRHAN DC.L DUMMY ;0 = OPENI
DC.L OPENO ;1 = OPENO
DC.L DUMMY ;2 = CHIN
IF DUMHAN
DC.L BYTEOUT ;3 = BYTEOUT, direct output
ELSE
DC.L CHOUT ;3 = CHOUT, with paging, tabs, etc.
ENDIF
DC.L CLOSE ;4 = CLOSE
DC.L GETINFO ;5 = GETINFO
DC.L BYTEOUT ;6 = BYTEOUT, low level output
DC.L DUMMY ;7 = spare
HPOSN DC.B 0 ;Horizontal position counter
; (first column = 0)
LINE DC.B 0 ;Line counter. Top line = 0
;----------------------------------------------------------------------
;Open (initialize) buffered terminal for output.
;
OPENO MOVE.L D0,-(SP) ;Save D0
BSR OPEN
IF EPSONHAN
MOVEQ #ESC,D0 ;Set elite mode (96 columns)
BSR BYTEOUT
MOVEQ #'M',D0
BSR BYTEOUT
ENDIF
IF ITOHAN
MOVEQ #ESC,D0 ;Set elite mode (96 columns)
BSR BYTEOUT
MOVEQ #'E',D0
BSR BYTEOUT
ENDIF
CLR.B LINE.L ;Init line counter to first line
BSR DOCR ;Make sure we're at the start of
; the line
MOVE.L (SP)+,D0 ;Restore D0
RTS
;----------------------------------------------------------------------
;Output the character in D0 to the printer.
; Handle some special characters: NUL, TAB, CR, & FF.
; This does not handle deletes (DEL).
;
CHOUT CMPI.B #$20,D0 ;Is it a control character?
BHS.S CHO190 ;Branch if not
CMPI.B #NUL,D0 ;Is it a null character?
BNE.S CHO110 ;Branch if not
DUMMY RTS ;Ignore nulls
CHO110 CMPI.B #TAB,D0 ;Is it a tab character?
BNE.S CHO120 ;Branch if not
BRA DOTAB ;(PBRA) Do tab and return
CHO120 CMPI.B #CR,D0 ;Is it a carriage return?
BNE.S CHO130 ;Branch if not
BRA NEWLIN ;(PBRA) Start a new line and return
CHO130 CMPI.B #FF,D0 ;Is it a form feed?
BNE.S CHO140 ;Branch if not
BRA NEWPAG ;(PBRA) Do page eject and return
CHO140 CMPI.B #BS,D0 ;Is it a backspace?
BNE.S CHO190 ;Branch if not
SUBQ.B #1,HPOSN.L ;Decrement X position
BRA BYTEOUT ;(PBRA) Output the character and return
CHO190 CMPI.B #LINESIZ,HPOSN.L ;Are we at the end of the line +1?
BLO.S CHO195 ;Branch if not
BSR DOCRLF ;Start a new line
CHO195 ADDQ.B #1,HPOSN.L ;Bump X position
BRA BYTEOUT ;(PBRA) Output the character and return
;----------------------------------------------------------------------
;Close the printer.
;
CLOSE BRA NEWPAG ;(PBRA) Eject page and return
;----------------------------------------------------------------------
;Return the address of the information array in D0.
;
GETINFO MOVE.L #INFO,D0
RTS
INFO DC.L START ;Starting and ending addresses of this
DC.L END ; handler
DC.L INFOSTR ;Description
IF EPSONHAN
INFOSTR ASCII 'EPSONHAN SEP-01-88 96-column Epson printer'
DC.B 0
ENDIF
IF ITOHAN
INFOSTR ASCII 'ITOHAN SEP-01-88 96-column C.Itoh printer'
DC.B 0
ENDIF
IF PARHAN
INFOSTR ASCII 'PARHAN SEP-01-88 80-column Generic printer'
DC.B 0
ENDIF
IF DUMHAN
INFOSTR ASCII 'DUMHAN SEP-01-88 Direct control of printer'
DC.B 0
ENDIF
;----------------------------------------------------------------------
;Space over to the next tab stop.
;
DOTAB MOVE.L D0,-(SP) ;Save D0
DOTAB10 MOVEQ #SPACE,D0 ;Output a space character
BSR BYTEOUT
ADDQ.B #1,HPOSN.L ;Bump X position
CMPI.B #LINESIZ,HPOSN.L ;Are we at the end of the line +1?
BLO.S DOTAB20 ;Branch if not
BSR DOCRLF ;Start a new line
DOTAB20 MOVE.B HPOSN.L,D0 ;Are we at the next tab stop?
ANDI.B #$07,D0
BNE.S DOTAB10 ;Branch if not
MOVE.L (SP)+,D0 ;Restore D0
RTS
;----------------------------------------------------------------------
;Move to the next line.
; Check for end-of-page.
;
NEWLIN BSR.S DOCRLF ;Move down a line
CMPI.B #60,LINE.L
BLO.S NL90 ;Branch if we are (we scroll)
BSR.S NEWPAG
NL90 RTS
;----------------------------------------------------------------------
;Advance to the beginning of the next page (form feed).
;
NEWPAG BSR.S DOCR ;Make sure we're in the left column
NP10 BSR.S DOLF ;Move down a line until we're at the
CMPI.B #66,LINE.L ; top of the next page
BLO.S NP10 ;6 lines per inch * 11 inches
CLR.B LINE.L ; = 66 lines. Reset line counter
RTS
;----------------------------------------------------------------------
;Advance to the beginning of the next line.
;
DOCRLF BSR.S DOCR ;Output a carriage return & a line feed
BRA.S DOLF ;(PBRA)
;----------------------------------------------------------------------
;Output a carriage return.
;
DOCR MOVE.L D0,-(SP) ;Save D0
MOVEQ #CR,D0 ;Output a carriage return
BSR.S BYTEOUT
CLR.B HPOSN.L ;Reset horizontal position to 0
MOVE.L (SP)+,D0 ;Restore D0
RTS
;----------------------------------------------------------------------
;Output a line feed.
;
DOLF MOVE.L D0,-(SP) ;Save D0
MOVEQ #LF,D0 ;Output a line feed
BSR.S BYTEOUT
ADDQ.B #1,LINE.L ;Count this line
MOVE.L (SP)+,D0 ;Restore D0
RTS
;======================================================================
;Initialize data direction registers.
;
OPEN MOVE.B #$FF,DDRB+CIAA.L ;Set outputs for Centronics interface
MOVE.B #$C0,DDRA+CIAB.L ;Set for Centronics interface
RTS
;----------------------------------------------------------------------
;Low-level routine to output the byte in D0 to the printer.
; Warning: The Amiga does a fast hardware strobe 3 cycles, about
; 500 ns, after the data is sent out. The printer is speced at 1 us.
;
BYTEOUT
BO10 BTST #0,PRA+CIAB.L ;Wait until not BUSY
BNE.S BO10 ; i.e until bit 0 is low
MOVE.B D0,PRB+CIAA.L ;Output byte in D0
RTS ; (Strobe handshake is automatic)
END EQU @-1 ;Address where this handler ends
;----------------------------------------------------------------------
;Hook this handler into the device-handler table.
;
ORG 4 *DEVNUM +DEVTBL
DC.L PRHAN
END
-----